package com.walking.monitor;

import com.alibaba.fastjson.JSONObject;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.SourceLocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @Description: 利用切面类前置通知打印请求参数
 * @Author: walking
 * @Date: 2019年12月31日
 */
@Aspect
@Component
public class ParamPrintMonitor {
    private static final Logger log = LoggerFactory.getLogger(ParamPrintMonitor.class);
    @Pointcut(value = "execution(* com.walking.controller.*.*(..))")
    public void cutPoint(){};
    @Before("cutPoint()")
    public void printParams(JoinPoint joinPoint){
        log.info(joinPoint.getSignature().toShortString()+" 请求参数:{}",JSONObject.toJSONString(joinPoint.getArgs()));
    }
}
